
package Telas;

import Conexao.ConectaBD;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;

/**
 *
 * @author Thalyson
 */
public class Tela_RegAnalise extends javax.swing.JFrame {

    Connection conecta;
    PreparedStatement pst;
    ResultSet rs;
    
    public Tela_RegAnalise() throws ClassNotFoundException {
        initComponents();
        setSize(1283, 653);
        setLocationRelativeTo(null);
        conecta = ConectaBD.conectabd();
        listarAnalise();
        selecionaTecnico();
        Icon();
    }

    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    private void Icon(){
    
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("assistec_icon.png")));
        
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void cadastrarAnalise() {
        String sql = "Insert into analise (Nome,Telefone,Email,Produto,Data,Status,Valor,Tecnico,Problema,Descriçao,Conclusao) values(?,?,?,?,?,?,?,?,?,?,?)";
        
        if(tf_nome.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Nome é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jf_telefone.getText().equals("(  )    -    ")){
        JOptionPane.showMessageDialog(null, "Campo Telefone é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_produto.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Produto é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jf_data.getText().equals("  /  /    ")){
        JOptionPane.showMessageDialog(null, "Campo Data é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jt_problema.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Problema é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(jt_descricao.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo Descrição é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_status.getSelectedItem().equals("STATUS")){
        JOptionPane.showMessageDialog(null, "Campo Status é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_status.getSelectedItem().equals("CONCLUÍDO")){
        JOptionPane.showMessageDialog(null, "Campo Status não pode contar como Concluído", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_status.getSelectedItem().equals("FECHADO")){
        JOptionPane.showMessageDialog(null, "Campo Status não pode contar como Fechado", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_tecnico.getSelectedItem().equals("TÉCNICO")){
        JOptionPane.showMessageDialog(null, "Campo Técnico é obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        
        
        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_nome.getText());            
            pst.setString(2, jf_telefone.getText());
            pst.setString(3, tf_email.getText());
            pst.setString(4, tf_produto.getText());
            pst.setString(5, jf_data.getText());
            pst.setString(6, cb_status.getSelectedItem().toString());
            pst.setString(7, tf_valor.getText());
            pst.setString(8, cb_tecnico.getSelectedItem().toString());
            pst.setString(9, jt_problema.getText());
            pst.setString(10, jt_descricao.getText());
            pst.setString(11, jt_conclusao.getText());

            pst.execute();
            JOptionPane.showMessageDialog(null, "Registrada com Sucesso!", "Registrada com Sucesso", JOptionPane.INFORMATION_MESSAGE);
            listarAnalise();
            Limpar();

        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }    
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void listarAnalise() {
        String sql = "Select *from analise order by Status Asc";
        try {
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();
            jt_analise.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void pesquisarClientes() {
        String sql = "Select *from analise where Nome like ?";

        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_pesquisar.getText() + "%");
            rs = pst.executeQuery();
            jt_analise.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void mostraItens() {
        int seleciona = jt_analise.getSelectedRow();
        tf_id.setText(jt_analise.getModel().getValueAt(seleciona, 0).toString());
        tf_nome.setText(jt_analise.getModel().getValueAt(seleciona, 1).toString());
        jf_telefone.setText(jt_analise.getModel().getValueAt(seleciona, 2).toString());
        tf_email.setText(jt_analise.getModel().getValueAt(seleciona, 3).toString());
        tf_produto.setText(jt_analise.getModel().getValueAt(seleciona, 4).toString());
        jf_data.setText(jt_analise.getModel().getValueAt(seleciona, 5).toString());
        cb_status.setSelectedItem(jt_analise.getModel().getValueAt(seleciona, 6).toString());
        tf_valor.setText(jt_analise.getModel().getValueAt(seleciona, 7).toString());
        cb_tecnico.setSelectedItem(jt_analise.getModel().getValueAt(seleciona, 8).toString());
        jt_problema.setText(jt_analise.getModel().getValueAt(seleciona, 9).toString());
        jt_descricao.setText(jt_analise.getModel().getValueAt(seleciona, 10).toString());
        jt_conclusao.setText(jt_analise.getModel().getValueAt(seleciona, 11).toString());
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void editarAnalise() {
        String sql = "Update analise set Nome = ?,Telefone = ?,Email = ?,Produto = ?,Data = ?,Status = ?,Valor = ?,Tecnico = ?,Problema = ?,Descriçao = ?,Conclusao = ? where id = ? ";
        
        if(cb_status.getSelectedItem().equals("STATUS")){
        JOptionPane.showMessageDialog(null, "Campo Status é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_tecnico.getSelectedItem().equals("TÉCNICO")){
        JOptionPane.showMessageDialog(null, "Campo Técnico é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        
        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_nome.getText());            
            pst.setString(2, jf_telefone.getText());
            pst.setString(3, tf_email.getText());
            pst.setString(4, tf_produto.getText());
            pst.setString(5, jf_data.getText());
            pst.setString(6, cb_status.getSelectedItem().toString());
            pst.setString(7, tf_valor.getText());
            pst.setString(8, cb_tecnico.getSelectedItem().toString());
            pst.setString(9, jt_problema.getText());
            pst.setString(10, jt_descricao.getText());
            pst.setString(11, jt_conclusao.getText());
            pst.setInt(12, Integer.parseInt(tf_id.getText()));
            pst.executeUpdate();
            JOptionPane.showMessageDialog(null, "Análise atualizada com sucesso");
            listarAnalise();

        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void deletarAnalise() {
        String sql = "Delete from analise where id = ?";

        try {
            pst = conecta.prepareStatement(sql);
            pst.setInt(1, Integer.parseInt(tf_id.getText()));
            pst.execute();
            listarAnalise();
        } catch (SQLException error) {

            JOptionPane.showMessageDialog(null, error);
        }
    }
    
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    
    private void selecionaTecnico() {

        try {
                
            String sql = "select * from funcionario";
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();                
            while (rs.next()) {
                String NomeProduto = rs.getString("Nome");
                cb_tecnico.addItem(NomeProduto);               
            }

        } catch (Exception e) {
        }

    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    
    
        public void Novo(){
        
            try {
                tf_nome.setEditable(true);
                jf_telefone.setEditable(true);
                tf_email.setEditable(true);
                tf_produto.setEditable(true);
                jf_data.setEditable(true);
                tf_valor.setEditable(true);
                jt_problema.setEditable(true);
                jt_descricao.setEditable(true);
                cb_status.setEnabled(true);
                cb_tecnico.setEnabled(true);
                jb_salvar.setEnabled(true);
                
                Limpar();                 
            } catch (Exception e) {
            }
        
        }
        
//<----------------------------------------------------------------------------------------------------------------------------------------->    
        
        public void Limpar(){
        
            try {
                
                tf_nome.setText("");
                jf_telefone.setText("");
                tf_email.setText("");
                tf_produto.setText("");
                jf_data.setText("");
                jt_problema.setText("");
                jt_descricao.setText("");
                jt_conclusao.setText("");
                tf_id.setText("");
                cb_status.setSelectedItem("STATUS");
                cb_tecnico.setSelectedItem("TÉCNICO");
                tf_valor.setText("");
                
            } catch (Exception e) {
            }
        
        }    
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator1 = new javax.swing.JSeparator();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jt_analise = new javax.swing.JTable();
        jb_regos = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jt_conclusao = new javax.swing.JTextArea();
        tf_pesquisar = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        tf_id = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        tf_produto = new javax.swing.JTextField();
        jf_data = new javax.swing.JFormattedTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        tf_email = new javax.swing.JTextField();
        jf_telefone = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        tf_nome = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jb_fechar = new javax.swing.JButton();
        jb_limpar = new javax.swing.JButton();
        jb_excluir = new javax.swing.JButton();
        jb_editar = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        jb_salvar = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        jt_descricao = new javax.swing.JTextArea();
        jScrollPane6 = new javax.swing.JScrollPane();
        jt_problema = new javax.swing.JTextArea();
        jLabel20 = new javax.swing.JLabel();
        cb_status = new javax.swing.JComboBox();
        tf_valor = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        cb_tecnico = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jb_novo = new javax.swing.JButton();
        jb_atualizar = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("AssisTec - Registrar Análise");
        setResizable(false);
        getContentPane().setLayout(null);

        jSeparator1.setForeground(new java.awt.Color(255, 255, 255));
        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(70, 560, 1210, 10);

        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("AssisTec");
        getContentPane().add(jLabel13);
        jLabel13.setBounds(10, 550, 60, 14);

        jt_analise.setAutoCreateRowSorter(true);
        jt_analise.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jt_analise.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jt_analise.setSelectionBackground(new java.awt.Color(0, 0, 0));
        jt_analise.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_analiseMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(jt_analise);

        getContentPane().add(jScrollPane4);
        jScrollPane4.setBounds(0, 310, 1280, 230);

        jb_regos.setBackground(new java.awt.Color(255, 255, 255));
        jb_regos.setText("REG. O.S.");
        jb_regos.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_regos.setBorderPainted(false);
        jb_regos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_regosActionPerformed(evt);
            }
        });
        getContentPane().add(jb_regos);
        jb_regos.setBounds(1010, 10, 100, 50);

        jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));

        jt_conclusao.setColumns(20);
        jt_conclusao.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jt_conclusao.setRows(5);
        jt_conclusao.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jt_conclusao.setSelectionColor(new java.awt.Color(0, 0, 0));
        jScrollPane1.setViewportView(jt_conclusao);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(670, 150, 320, 150);

        tf_pesquisar.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_pesquisar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_pesquisar.setSelectionColor(new java.awt.Color(0, 0, 0));
        tf_pesquisar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tf_pesquisarKeyReleased(evt);
            }
        });
        getContentPane().add(tf_pesquisar);
        tf_pesquisar.setBounds(1020, 270, 250, 30);

        jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_lupa.png"))); // NOI18N
        getContentPane().add(jLabel17);
        jLabel17.setBounds(1000, 270, 20, 30);

        jLabel16.setBackground(new java.awt.Color(255, 255, 255));
        jLabel16.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(255, 255, 255));
        jLabel16.setText("PESQUISAR CLIENTE");
        getContentPane().add(jLabel16);
        jLabel16.setBounds(1020, 250, 150, 14);

        tf_id.setEditable(false);
        tf_id.setBackground(new java.awt.Color(255, 255, 255));
        tf_id.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_id.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_id.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_id);
        tf_id.setBounds(1060, 130, 50, 30);

        jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("REGISTRAR ANÁLISE");
        getContentPane().add(jLabel11);
        jLabel11.setBounds(1140, 170, 130, 14);

        jLabel10.setBackground(new java.awt.Color(255, 255, 255));
        jLabel10.setForeground(new java.awt.Color(78, 78, 78));
        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_analisar.jpeg"))); // NOI18N
        jLabel10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        getContentPane().add(jLabel10);
        jLabel10.setBounds(1120, 10, 150, 150);

        tf_produto.setEditable(false);
        tf_produto.setBackground(new java.awt.Color(255, 255, 255));
        tf_produto.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_produto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_produto.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_produto);
        tf_produto.setBounds(580, 30, 180, 30);

        jf_data.setEditable(false);
        jf_data.setBackground(new java.awt.Color(255, 255, 255));
        jf_data.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_data.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_data.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_data.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_data);
        jf_data.setBounds(770, 30, 80, 30);

        jLabel9.setBackground(new java.awt.Color(255, 255, 255));
        jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("DATA");
        getContentPane().add(jLabel9);
        jLabel9.setBounds(770, 10, 70, 14);

        jLabel19.setBackground(new java.awt.Color(255, 255, 255));
        jLabel19.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel19.setForeground(new java.awt.Color(255, 255, 255));
        jLabel19.setText("PRODUTO");
        getContentPane().add(jLabel19);
        jLabel19.setBounds(580, 10, 70, 14);

        jLabel5.setBackground(new java.awt.Color(255, 255, 255));
        jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("EMAIL");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(360, 10, 40, 14);

        tf_email.setEditable(false);
        tf_email.setBackground(new java.awt.Color(255, 255, 255));
        tf_email.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_email.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_email.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_email);
        tf_email.setBounds(360, 30, 210, 30);

        jf_telefone.setEditable(false);
        jf_telefone.setBackground(new java.awt.Color(255, 255, 255));
        jf_telefone.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_telefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_telefone.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_telefone.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_telefone);
        jf_telefone.setBounds(240, 30, 110, 30);

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("TELEFONE");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(240, 10, 70, 14);

        tf_nome.setEditable(false);
        tf_nome.setBackground(new java.awt.Color(255, 255, 255));
        tf_nome.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_nome.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_nome.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_nome);
        tf_nome.setBounds(10, 30, 220, 30);

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("NOME DO CLIENTE");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(10, 10, 130, 14);

        jLabel7.setBackground(new java.awt.Color(255, 255, 255));
        jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("DESCRIÇÃO DO PROBLEMA DO PRODUTO");
        getContentPane().add(jLabel7);
        jLabel7.setBounds(10, 130, 260, 14);

        jLabel8.setBackground(new java.awt.Color(255, 255, 255));
        jLabel8.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("DESCRIÇÃO DO PRODUTO");
        getContentPane().add(jLabel8);
        jLabel8.setBounds(340, 130, 170, 14);

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("CONCLUSÃO DA ANÁLISE");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(670, 130, 170, 14);

        jb_fechar.setBackground(new java.awt.Color(255, 255, 255));
        jb_fechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fechar.png"))); // NOI18N
        jb_fechar.setText("FECHAR");
        jb_fechar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_fechar.setBorderPainted(false);
        jb_fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_fecharActionPerformed(evt);
            }
        });
        getContentPane().add(jb_fechar);
        jb_fechar.setBounds(1170, 570, 100, 50);

        jb_limpar.setBackground(new java.awt.Color(255, 255, 255));
        jb_limpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_limpar.png"))); // NOI18N
        jb_limpar.setText("LIMPAR");
        jb_limpar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_limpar.setBorderPainted(false);
        jb_limpar.setEnabled(false);
        jb_limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_limparActionPerformed(evt);
            }
        });
        getContentPane().add(jb_limpar);
        jb_limpar.setBounds(1070, 570, 100, 50);

        jb_excluir.setBackground(new java.awt.Color(255, 255, 255));
        jb_excluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_deletar.png"))); // NOI18N
        jb_excluir.setText("EXCLUIR");
        jb_excluir.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_excluir.setBorderPainted(false);
        jb_excluir.setEnabled(false);
        jb_excluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_excluirActionPerformed(evt);
            }
        });
        getContentPane().add(jb_excluir);
        jb_excluir.setBounds(970, 570, 100, 50);

        jb_editar.setBackground(new java.awt.Color(255, 255, 255));
        jb_editar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_editar.png"))); // NOI18N
        jb_editar.setText("EDITAR");
        jb_editar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_editar.setBorderPainted(false);
        jb_editar.setEnabled(false);
        jb_editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_editarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_editar);
        jb_editar.setBounds(870, 570, 100, 50);

        jLabel15.setBackground(new java.awt.Color(255, 255, 255));
        jLabel15.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("ID");
        getContentPane().add(jLabel15);
        jLabel15.setBounds(1060, 110, 30, 20);

        jb_salvar.setBackground(new java.awt.Color(255, 255, 255));
        jb_salvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_salvar.png"))); // NOI18N
        jb_salvar.setText("SALVAR");
        jb_salvar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_salvar.setBorderPainted(false);
        jb_salvar.setEnabled(false);
        jb_salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_salvarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_salvar);
        jb_salvar.setBounds(770, 570, 100, 50);

        jScrollPane5.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));

        jt_descricao.setEditable(false);
        jt_descricao.setColumns(20);
        jt_descricao.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jt_descricao.setRows(5);
        jt_descricao.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jt_descricao.setSelectionColor(new java.awt.Color(0, 0, 0));
        jScrollPane5.setViewportView(jt_descricao);

        getContentPane().add(jScrollPane5);
        jScrollPane5.setBounds(340, 150, 320, 150);

        jScrollPane6.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));

        jt_problema.setEditable(false);
        jt_problema.setColumns(20);
        jt_problema.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jt_problema.setRows(5);
        jt_problema.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jt_problema.setSelectionColor(new java.awt.Color(0, 0, 0));
        jScrollPane6.setViewportView(jt_problema);

        getContentPane().add(jScrollPane6);
        jScrollPane6.setBounds(10, 150, 320, 150);

        jLabel20.setBackground(new java.awt.Color(255, 255, 255));
        jLabel20.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel20.setForeground(new java.awt.Color(255, 255, 255));
        jLabel20.setText("STATUS");
        getContentPane().add(jLabel20);
        jLabel20.setBounds(10, 70, 60, 14);

        cb_status.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_status.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "STATUS", "OBSERVAÇÃO", "CONCLUÍDO", "FECHADO" }));
        cb_status.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_status.setEnabled(false);
        getContentPane().add(cb_status);
        cb_status.setBounds(10, 90, 140, 30);

        tf_valor.setEditable(false);
        tf_valor.setBackground(new java.awt.Color(255, 255, 255));
        tf_valor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_valor.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_valor);
        tf_valor.setBounds(160, 90, 80, 30);

        jLabel18.setBackground(new java.awt.Color(255, 255, 255));
        jLabel18.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel18.setForeground(new java.awt.Color(255, 255, 255));
        jLabel18.setText("VALOR R$");
        getContentPane().add(jLabel18);
        jLabel18.setBounds(160, 70, 60, 14);

        cb_tecnico.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_tecnico.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TÉCNICO" }));
        cb_tecnico.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_tecnico.setEnabled(false);
        getContentPane().add(cb_tecnico);
        cb_tecnico.setBounds(250, 90, 230, 30);

        jLabel12.setBackground(new java.awt.Color(255, 255, 255));
        jLabel12.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("TÉCNICO RESPONSÁVEL");
        getContentPane().add(jLabel12);
        jLabel12.setBounds(250, 70, 160, 14);

        jb_novo.setBackground(new java.awt.Color(255, 255, 255));
        jb_novo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_novo.png"))); // NOI18N
        jb_novo.setText("NOVO");
        jb_novo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_novo.setBorderPainted(false);
        jb_novo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_novoActionPerformed(evt);
            }
        });
        getContentPane().add(jb_novo);
        jb_novo.setBounds(10, 570, 100, 50);

        jb_atualizar.setBackground(new java.awt.Color(255, 255, 255));
        jb_atualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_atualizar.png"))); // NOI18N
        jb_atualizar.setText("ATUALIZAR");
        jb_atualizar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_atualizar.setBorderPainted(false);
        jb_atualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_atualizarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_atualizar);
        jb_atualizar.setBounds(110, 570, 100, 50);

        jLabel27.setBackground(new java.awt.Color(255, 255, 255));
        jLabel27.setForeground(new java.awt.Color(255, 255, 255));
        jLabel27.setText("TABELA DE ANÁLISES");
        getContentPane().add(jLabel27);
        jLabel27.setBounds(570, 540, 130, 20);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fundo2.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 1280, 650);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jt_analiseMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jt_analiseMouseClicked
        mostraItens();
        cb_status.setEnabled(true);
        jb_editar.setEnabled(true);
        jb_limpar.setEnabled(true);
        jb_excluir.setEnabled(true);
        jb_salvar.setEnabled(false);
        
                tf_nome.setEditable(true);
                jf_telefone.setEditable(true);
                tf_email.setEditable(true);
                tf_produto.setEditable(true);
                jf_data.setEditable(true);
                tf_valor.setEditable(true);
                jt_problema.setEditable(true);
                jt_descricao.setEditable(true);
                cb_status.setEnabled(true);
                cb_tecnico.setEnabled(true);
                jb_salvar.setEnabled(false);
    }//GEN-LAST:event_jt_analiseMouseClicked

    private void jb_regosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_regosActionPerformed
        Tela_RegOS tros = null;
        try {
            tros = new Tela_RegOS();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Tela_RegAnaliseBasico.class.getName()).log(Level.SEVERE, null, ex);
        }
        tros.setVisible(true);
    }//GEN-LAST:event_jb_regosActionPerformed

    private void tf_pesquisarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tf_pesquisarKeyReleased
        pesquisarClientes();
    }//GEN-LAST:event_tf_pesquisarKeyReleased

    private void jb_fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_fecharActionPerformed

        dispose();
    }//GEN-LAST:event_jb_fecharActionPerformed

    private void jb_limparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_limparActionPerformed

        tf_nome.setText("");
        jf_telefone.setText("");
        tf_email.setText("");
        jf_data.setText("");
        tf_produto.setText("");
        jt_problema.setText("");
        jt_descricao.setText("");
        jt_conclusao.setText("");
        tf_id.setText("");
        cb_status.setSelectedItem("STATUS");
        cb_tecnico.setSelectedItem("TÉCNICO");
        tf_valor.setText("");
        
    }//GEN-LAST:event_jb_limparActionPerformed

    private void jb_excluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_excluirActionPerformed
        deletarAnalise();
    }//GEN-LAST:event_jb_excluirActionPerformed

    private void jb_editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_editarActionPerformed
        editarAnalise();
    }//GEN-LAST:event_jb_editarActionPerformed

    private void jb_salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_salvarActionPerformed
        cadastrarAnalise();
    }//GEN-LAST:event_jb_salvarActionPerformed

    private void jb_novoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_novoActionPerformed
        Novo();
        jb_editar.setEnabled(false);
        jb_excluir.setEnabled(false);
        jb_limpar.setEnabled(true);
    }//GEN-LAST:event_jb_novoActionPerformed

    private void jb_atualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_atualizarActionPerformed
        listarAnalise();
        jb_editar.setEnabled(false);
        jb_excluir.setEnabled(false);
    }//GEN-LAST:event_jb_atualizarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Tela_RegAnalise.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Tela_RegAnalise.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Tela_RegAnalise.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Tela_RegAnalise.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new Tela_RegAnalise().setVisible(true);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(Tela_RegAnalise.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cb_status;
    private javax.swing.JComboBox cb_tecnico;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton jb_atualizar;
    private javax.swing.JButton jb_editar;
    private javax.swing.JButton jb_excluir;
    private javax.swing.JButton jb_fechar;
    private javax.swing.JButton jb_limpar;
    private javax.swing.JButton jb_novo;
    private javax.swing.JButton jb_regos;
    private javax.swing.JButton jb_salvar;
    private javax.swing.JFormattedTextField jf_data;
    private javax.swing.JFormattedTextField jf_telefone;
    private javax.swing.JTable jt_analise;
    private javax.swing.JTextArea jt_conclusao;
    private javax.swing.JTextArea jt_descricao;
    private javax.swing.JTextArea jt_problema;
    private javax.swing.JTextField tf_email;
    private javax.swing.JTextField tf_id;
    private javax.swing.JTextField tf_nome;
    private javax.swing.JTextField tf_pesquisar;
    private javax.swing.JTextField tf_produto;
    private javax.swing.JTextField tf_valor;
    // End of variables declaration//GEN-END:variables
}
